<template>
  <el-container direction="vertical">
    <div class="header-container">
      <img :src="require('@/assets/images/a-danghui.png')" alt="" @click="$router.push('/')">
      <p>淮南统一战线门户网站管理平台{{ baseEnv !== 'production' ? '测试系统' : '' }}</p>
      <div class="user-info-container">
        <p class="back" @click="$router.push('/')">返回前台</p>
        <p v-if="userInfo">{{ userInfo.name }}</p>
        <el-dropdown style="margin-left: 10px" v-if="userInfo" >
          <p class="leave"><i class="el-icon-arrow-down" /></p>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="logout">退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
    <el-container>
      <el-aside>
        <SlideMenu />
      </el-aside>
      <el-main>
        <router-view v-slot="{ Component }">
          <transition name="move" mode="out-in">
            <keep-alive>
              <component :is="Component" />
            </keep-alive>
          </transition>
        </router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import SlideMenu from '@/components/layout/SlideMenu';
import store from '@/store';
import { clearInfo } from '@/utils/request';
import { Logout } from '@/api';
export default {
  name: 'Manager',
  components: {
    SlideMenu
  },
  data() {
    return {
      baseEnv: process.env.VUE_APP_ENV
    }
  },
  computed: {
    userInfo() {
      return store.state.user.user_info || null;
    }
  },
  mounted() {},
  methods: {
    logout() {
      Logout().then(res => {
        clearInfo();
        this.$router.push('/login');
      })
    }
  }
}
</script>

<style scoped lang="scss">
.header-container{
  width: 100%;
  height: 100px;
  background-color: #fff;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  position: relative;
  img{
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-left: 2%;
    cursor: pointer;
  }
  p{
    margin-left: 20px;
    font-size: 32px;
    //color: #254c8A;
    color: #d42d1f;
    font-weight: 600;
  }
  .user-info-container{
    height: 100%;
    position: absolute;
    top: 0;
    right: 2%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    .back{
      font-size: 22px;
      color: #333;
      font-weight: 500;
      font-family: "PingFang SC",serif;
      cursor: pointer;
      margin-top: 1px;
    }
    p{
      font-size: 24px;
      color: #333;
      font-weight: 400;
      font-family: "PingFang SC",serif;
    }
    .leave{
      width: 50px;
      cursor: pointer;
    }
  }
}
.el-container {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  background-color: #254c8A;

  .el-aside {
    height: 100%;
    width: 15% !important;
    box-sizing: border-box;
  }
  ::v-deep .el-main {
    width: 85%;
    background-color: #f0f0f0;
    padding: 10px;
  }
}
</style>
